#ifndef __GLF_APPEVENT_H_INCLUDED__
#define __GLF_APPEVENT_H_INCLUDED__

#include <glf/core/event.h>

namespace glf
{

	//AppEventType
	enum AppEventType 
	{
		AET_ORIENTATION = APP_EVENT_TYPE_BASE,
		AET_SYSTEM,
		AET_DISPLAY,
		APP_EVENT_END
	};

	//OrientationEventType 
	//! [Sended messages]
	enum OrientationEventType 
	{
		//dont change the order of the aspects
		OET_ASPECTPORTRAIT,				//normal position
		OET_ASPECTPORTRAIT_REVERSED,	//upside down
		OET_ASPECTLANDSCAPE_RIGHT,		//bottom on the right
		OET_ASPECTLANDSCAPE_LEFT,		//bottom on the left
		OET_ASPECTFACE_UP,
		OET_ASPECTFACE_DOWN
	};	

	//SystemEventType
	//! [Sended messages]
	enum SystemEventType
	{
		SET_LOWBATTERY,
		SET_BECAME_ACTIVE,
		SET_WILL_RESIGN_ACTIVE,
		SET_WILL_TERMINATE,
		SET_ENTERBACKGROUND,
		SET_ENTERFOREGROUND,
		SET_LOW_MEMORY,
		//deprecated: use items without IPHONE
		SET_IPHONE_BECAME_ACTIVE		= SET_BECAME_ACTIVE,
		SET_IPHONE_WILL_RESIGN_ACTIVE	= SET_WILL_RESIGN_ACTIVE,
		SET_IPHONE_WILL_TERMINATE		= SET_WILL_TERMINATE,
		SET_IPHONE_ENTERBACKGROUND		= SET_ENTERBACKGROUND,
		SET_IPHONE_ENTERFOREGROUND		= SET_ENTERFOREGROUND,
		SET_IPHONE_LOW_MEMORY			= SET_LOW_MEMORY
	};
	
	//DisplayEventType
	enum DisplayEventType
	{
		//! A new display is connecting, the default resolution could be updated
		//! [Sended message from UI thread]
		DET_CONNECTING,
		//! A new display is connected and the graphical surface is created
		//! [Posted message]
		DET_CONNECTED,
		//! A display is disconnecting, ressources must be freed now
		//! [Sended message from UI thread]
		DET_DISCONNECTING,
		//! A display is disconnected and the graphical surface is destroyed
		//! [Posted message]
		DET_DISCONNECTED,
		//! A display has changed of resolution
		//! [Posted message]
		DET_SCREEN_RESIZED
	};

	//Orientation Event
	struct OrientationEvent : public CoreEvent
	{
	public:
		OrientationEvent(OrientationEventType subType) : CoreEvent(AET_ORIENTATION),
			mSubType(subType)
		{
		}
	public:
		OrientationEventType mSubType;
	};	

	//SystemEvent
	struct SystemEvent : public CoreEvent
	{
	public:
		SystemEvent(SystemEventType subType) : CoreEvent(AET_SYSTEM),
			mSubType(subType)
		{
		}
	public:
		SystemEventType mSubType;
	};

	//DisplayEvent
	struct DisplayEvent : public CoreEvent
	{
	public:
		DisplayEvent(DisplayEventType subType) : CoreEvent(AET_DISPLAY),
			mCurrentResolution(0),
			mRank(0),
			mResolutionCount(1),
			mSubType((glf::uchar)subType)
		{
			mResolutions[0].x = 0;
			mResolutions[0].y = 0;
		}

	public:
		//! If DET_CONNECTING: Array of available resolutions
		//! If DET_CONNECTED OR DET_SCREEN_RESIZED: current resolution at index 0
		//! Else: empty
		Point<ushort> mResolutions[16];
		//! If DET_CONNECTING: Index of default resolution (could be updated)
		//! Else: 0
		mutable uchar mCurrentResolution;		
		//! Index of the display (0: main display, 1: second display, ...)
		uchar mRank;
		//! If DET_CONNECTING: Number of available resolutions
		//! Else: 1
		uchar mResolutionCount;	
		//! Any subtype event present in DisplayEventType
		uchar mSubType;
	};

} //eon glf

#endif //__GLF_APPEVENT_H_INCLUDED__
